﻿<!DOCTYPE >
<html>
<head>
    <title>微街秀 > 费用充值</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width,height=device-height,inital-scale=1.0,maximum-scale=1.0,user-scalable=no;" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <meta name="format-detection" content="telephone=no" />
    <link rel="stylesheet" type="text/css" href="css/css.css" />
    <link href="css/Makeset.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
    .radius{width: 15px; height: 15px; border: #F37B0B 1px solid; border-radius: 15px;float: left;text-align: center; line-height: 16px;color: white;}
    </style>
</head>
<body style="background-color: white;">
    <div class="wamtop">
        <div class="topleft" onclick="javascript:history.back(-1);">
            <img src="img/5.jpg" />
        </div>
        <div class="topcententxt">
            费用充值
        </div>
    </div>    
    <div style="position: relative; width: 100%">
        <div style="text-align: center; width: 100%; margin-top: 35px;">
            <input type="number" placeholder="请输入充值金额（元）" class="op_price" style="width: 95%; height: 30px;line-height: 30px;
                border-radius: 5px; border: #F37B0B 1px solid; padding-left: 10px;">
        </div>
        <div style="width: 200px; position: absolute; top: 40px; left: 40px;"  class="Cz">
            <div class="zfb radius" style="background-color: rgb(243, 123, 11);">
       &#10003;
            </div>
            <div style="margin-left: 25px; color:#8F8F8F;" >
                支付宝充值</div>
        </div>
        <div style="width: 130px; position: absolute; top: 40px; right: 0; display:none;" class="Cz">
            <div class="wx radius">
       &#10003;
            </div>
            <div style="margin-left: 25px;color:#8F8F8F;">
                微信充值</div>
        </div>
        <div class="shared" style="width: 95%; color: white; background-color: #F37B0B; height: 40px;
            margin: 30% auto 0 auto; text-align: center; line-height: 40px; border-radius: 5px;
            font-size: 16px;">
            确定</div>
    </div>
    <script src="js/jquery-2.1.4.min.js" type="text/javascript"></script>
    <script src="js/ajax-data.js" type="text/javascript"></script>
    <script src="js/base.js" type="text/javascript"></script>
    <script src="js/dialog.js" type="text/javascript"></script>
    <script>
        var page = 1;
        $(document).ready(function () {
            $(".shared").bind("click", Recharge);  //分享事件

            $(".Cz").click(function () {
                $(".radius").css("background-color", "");
                $(this).children(".radius").css("background-color", "#F37B0B");
            });

        });

        function Recharge() {
            var totalmoney = GetMoney();
            if (isNaN(totalmoney)) {
                Alert("请填写充值金额")
                return;
            }
            if (totalmoney < 1) {
                Alert("充值金额必需大于1元");
                return;
            }

            if (navigator.userAgent.indexOf("wjx") == -1) {
                Alert("请使用客户端APP");
                return;
            }
            if (!confirm("充值金额为：" + totalmoney + "元，确定提交吗"))
                return;
            AddOrder();
        }

        function AddOrder() {
            var article_id = "0";
            var total_price = GetMoney();
            var pay_price = GetMoney();
            var unit_price = $(".op_price").val();
            var number = 1;
            var platform = $(".zfb").css("background-color").indexOf("rgba") > -1 ? 1 : 2;       
         
            var param = "article_id=" + article_id + "&total_price=" + total_price + "&pay_price=" + pay_price + "&unit_price=" + unit_price + "&number=" + number + "&platform=" + platform;

            AjaxStart("ajax/fc_order.ashx?addorder&rand=" + Math.random(), param, function (json) {
                if (json.code == 0)
                    GoPay(platform, json.item);
                else
                    Alert(json.msg);
            });
        }

        function GoPay(platform, item) {
            //微信支付
            if (platform == 1) {
                var param = { subject: "微街秀充值", body: "微街秀充值", money: parseFloat(GetWXMoney()), outTradeNo: item.orderid, notifyUrl: "http://wjxtest.711688.com/client/api/wx_notify.aspx", callback: "payCallback" };
                window.location.href = "callback://weixinPay?" + JSON.stringify(param);
            }
            else if (platform == 2) {
                var param = { "subject": "微街秀充值", "body": "微街秀充值", "price": GetMoney(), "out_trade_no": item.orderid, "notify_url": item.notify_url, "callback": "payCallback" };
                window.location.href = "callback://alipay?" + JSON.stringify(param);
            }
        }

        function payCallback() {
            window.location.href = "makeoutcome.html";
        }

        function GetMoney() {
            var money = parseFloat($(".op_price").val());    ////最小单位：元
            return money.toFixed(2).toString();
        }
        function GetWXMoney() {
            var money = parseFloat($(".op_price").val()) * 100;  //最小单位：分
            return money.toFixed(2);
        }
    </script>
</body>
</html>
